/////////////////////////////////////////////////////////////////////////////
// Purpose:     Improvement of std::list
// Author:      Jesus Gonzalez
// Modified by:
// Copyright:   (c) 2003-2013 Jesus Gonzalez <jgonzalez@gdr-sistemas.com>
// License:     BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _SMARTLIB_SMARTLIST_H_
#define _SMARTLIB_SMARTLIST_H_

/**
 * \file
 * Improvement of std::list.
 */

#include <list>

/**
 * The SmartList template class is an extension of the STL \p list class that dynamically manages
 * the objects that it contains.
 */
template< typename T >
class SmartList : public std::list<T*>
{
public:
	virtual ~SmartList()
	{
		clear();
	}

    /**
     * Clears all the objects of the container, dynamically deallocting them.
     */
	virtual void clear()
	{
		remove_if( _deleteT );
	}

private:
	static bool _deleteT( T* e ) { delete e; return true; }
};

#endif // _SMARTLIB_SMARTLIST_H_
